package main

import (
	"fmt"
	"runtime"
	"time"
)

func main() {
	go func() {
		fmt.Println("start")
		runtimetest2()
		fmt.Println("end")
	}()

	time.Sleep(time.Second * 3)
}

func runtimetest() {

	fmt.Println("testfunction start")
	runtime.Goexit() //直接终止整个程序
	fmt.Println("function end")
}

func runtimetest1() {
	fmt.Println("GoRoot Path", runtime.GOROOT()) //gopath 目录地址
	fmt.Println(runtime.GOOS)                    //获取操作系统
	fmt.Println("CPU个数", runtime.NumCPU())       //获取cpu的个数
}

func runtimetest2() {

	go func() {
		for i := 0; i < 5; i++ {
			fmt.Println(i, "function")

		}

	}()

	for i := 0; i < 5; i++ {

		runtime.Gosched() //作用让其他goroutine先执行
		fmt.Println(i, "main")

	}

}
